% M-PAM Modulation

M = 2;

dmin = 2; %distancia minima entre simbolos

sm = modem.pammod('M', M, 'SymbolOrder', 'Gray', 'InputType', 'Integer');

% Create a scatter plot
scatterPlot = commscope.ScatterPlot('SamplesPerSymbol',1, 'Constellation',sm.Constellation);
% Show constellation
scatterPlot.PlotSettings.Constellation = 'on';
scatterPlot.PlotSettings.ConstellationStyle = 'rd';

% Add symbol labels
hold on;
k=log2(sm.M);
for jj=1:sm.M
        text(real(sm.Constellation(jj))-0.15, imag(sm.Constellation(jj))+0.15, dec2base(sm.SymbolMapping(jj),2,k));
end
hold off;
